var config = {
    //api: 'http://106.14.133.80/',
    api: 'http://www.iayoyo.com/'
    //api: 'http://127.0.0.1:3000/'
}
$(function(){
    $("#photo").on('change',function(){
        var file=this.files[0];
        if(!/image\/\w+/.test(file.type)){ 
            alert("请确保文件为图像类型"); 
            return false; 
        }
        var reader=new FileReader();
        reader.readAsDataURL(file);
        reader.onload=function(){
            $(".thumbnail>img").attr('src',this.result);
        }
    });
    $("#svuinfo").on('click',function(){
        var data = new FormData();
        data.append("photopath",  $("#photo")[0].files[0]);
        data.append("name",$("#username").val());
        data.append("id",$("#username").attr('uid'));
        $.ajax({
            type: 'post',
            url: config.api+'user/update',
            contentType: false,
            processData: false,
            data: data
        }).done(function(result){
            if(result.success){
                location.href = 'logout';
            }
        }).fail(function(){

        })
    })
})